package com.ning.activitys.skysound.game;

import android.content.Context;
import android.util.AttributeSet;
import android.view.Gravity;
import android.widget.FrameLayout;
import android.widget.TextView;

/**
 * Created by dllo on 16/1/24.
 */
public class Card extends FrameLayout{

    private int number = 0;
    private TextView card_number;

    public Card(Context context) {
        super(context);

        card_number = new TextView(getContext());
        card_number.setTextSize(32);
        card_number.setGravity(Gravity.CENTER);
        card_number.setBackgroundColor(0x33ffffff);
        //-1,-1充满父容器
        LayoutParams layoutParams = new LayoutParams(-1,-1);
        //设置卡片的Margins
        layoutParams.setMargins(10,10,0,0);
        addView(card_number,layoutParams);

        setNumber(2);

    }



    public int getNumber() {
        return number;
    }

    public void setNumber(int number) {
        this.number = number;

        if (number <= 0) {
            card_number.setText("");
        } else {
            card_number.setText(number + "");
        }
    }

    //用equals方法判断两个卡片的数字是否相等
    public boolean equals(Card o) {
        return getNumber() == o.getNumber();
    }

}
